<?php
session_start();

function redirect($page) {
    header('Location: ' . $page);
    exit;
}

if (isset($_SESSION['username'])) {
    session_destroy();
    redirect("index.php");
}
?>     